home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / surfsrc3.zip / CHKCMMD.INC < prev    next >
Text File  |  1991-09-07  |  2KB  |  68 lines

  1. procedure CHKCMMD (var Cmmd: cmmdtype; var Parm: parmtype; var Ipos: integer;
  2.     line: text255);
  3. { Check for the presence of one of the SURFMODL symbolic commands at the
  4.   beginning of the line, and set Ipos to point immediately after the colon.
  5. }
  6. var i: integer;
  7.     p: integer;
  8.     Srch: string[30];           { search string }
  9.     Astrsk: integer;            { pos of asterisk on line }
  10.     Nline: text255;             { copy of Line after removing cmmd }
  11.     Sym: boolean;               { is the command have symbolic param? }
  12.  
  13. begin
  14.  
  15.   { Avoid searching if not starting with an alpha: }
  16.   if (line[1] < 'A') or (line[1] > 'Z') then begin
  17.     Cmmd := CMD_NONE;
  18.     exit;
  19.   end;
  20.  
  21.   { Got a command - see what it is }
  22.  
  23.   i := 1;
  24.   Cmmd := CMD_INVALID;
  25.   Sym := FALSE;
  26.   while (i <= MAXCMMD) and (Cmmd = CMD_INVALID) do begin
  27.     with cmmd_name[i] do begin
  28.       Srch := Cname + ':';
  29.       p := pos (Srch, line);
  30.       if (p = 1) then begin
  31.         Cmmd := Ctype;
  32.         Ipos := length (Srch) + 1;
  33.         Sym := Sym_param;
  34.       end;
  35.     end; { with }
  36.     i := i + 1;
  37.   end; { while }
  38.  
  39.   { If command accepts a symbolic parameter, read it: }
  40.   if (Sym) then begin
  41.     { First check for a comment.  Start looking after the command string: }
  42.     Nline := copy (Line, Ipos, 255);
  43.     Astrsk := pos ('*', Nline);
  44.     if (Astrsk = 0) then
  45.       Astrsk := 999;
  46.     i := 1;
  47.     Parm := PRM_NONE;
  48.     while (i <= MAXPARM) and (Parm = PRM_NONE) do begin
  49.       with parm_name[i] do begin
  50.         p := pos (Pname, Nline);
  51.         if (p > 0) and (p < Astrsk) then begin
  52.           { Found a parameter before the comment begins. }
  53.           Parm := Ptype;
  54.           { Position at EOL so no more processing performed in Inreal }
  55.           Ipos := length (Line) + 1;
  56.         end;
  57.       end; { with }
  58.       i := i + 1;
  59.     end; { while }
  60.  
  61.     if (Parm = PRM_NONE) then
  62.       { No symbolic parameter found }
  63.       Cmmd := CMD_INVALID;
  64.   end; { if Sym }
  65.  
  66. end; { procedure CHKCMMD }
  67.  
  68.